package com.meituan.catering.management.product.biz.model.converter;

import com.meituan.catering.management.product.biz.model.ProductBO;
import com.meituan.catering.management.product.dao.model.ProductAccessoryDO;
import com.meituan.catering.management.product.dao.model.ProductDO;
import com.meituan.catering.management.product.dao.model.ProductMethodDO;

/**
 * 从其他数据模型向商品BO的转换器
 */
public abstract class ProductBOConverter {


    public static ProductBO fromDO(ProductDO productDO) {
        if (productDO == null) {
            return null;
        } else {
            ProductBO productBO = new ProductBO();
            productBO.setTenantId(productDO.getTenantId());
            productBO.setId(productDO.getId());
            productBO.setDescription(productDO.getDescription());
            productBO.setEnabled(productDO.getEnabled());
            productBO.setIncreaseSalesQuantity(productDO.getIncreaseSalesQuantity());
            productBO.setMinSalesQuantity(productDO.getMinSalesQuantity());
            productBO.setName(productDO.getName());
            productBO.setUnitPrice(productDO.getUnitPrice());
            productBO.setVersion(productDO.getVersion());
            productBO.setUnitOfMeasure(productDO.getUnitOfMeasure());
            /*
             * 审计信息
             */
            productBO.getAuditing().setCreatedAt(productDO.getCreatedAt());
            productBO.getAuditing().setCreatedBy(productDO.getCreatedBy());
            productBO.getAuditing().setLastModifiedAt(productDO.getLastModifiedAt());
            productBO.getAuditing().setLastModifiedBy(productDO.getLastModifiedBy());

            return productBO;
        }

    }


    /**
     * 做法DO转BO
     */
    public static ProductBO.MethodGroup.Option fromDOToMethOption(ProductMethodDO productMethodDO){

        ProductBO.MethodGroup.Option option=new ProductBO.MethodGroup.Option();
        option.setId(productMethodDO.getId());
        option.setName(productMethodDO.getName());
        return option;
    }

    /**
     * 加料 DO转BO
     */
    public static ProductBO.AccessoryGroup.Option fromDOToAccOption(ProductAccessoryDO productAccessoryDO){
        ProductBO.AccessoryGroup.Option option=new ProductBO.AccessoryGroup.Option();
        option.setId(productAccessoryDO.getId());
        option.setUnitPrice(productAccessoryDO.getUnitPrice());
        option.setName(productAccessoryDO.getName());
        option.setUnitOfMeasure(productAccessoryDO.getUnitOfMeasure());

        return option;

    }



}
